﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QString str1="Aa";
    QString str2=str1;
    QString str3("姚哥");
    QString str4(str1);
    //str1.insert(6,'a');
    str1.replace("a","人才",Qt::CaseInsensitive);
    qDebug()<<str1;
    QString str5="16";
    bool ret;
    int num=str5.toInt(&ret,16);
    if(ret)
    {
        qDebug()<<"转换成功"<<num;
    }
    else
    {
        qDebug()<<"转换失败"<<num;
    }


    str1.remove("人");
    qDebug()<<str1;

    QString str6="abb床前明月光";
    QString str7=str6.right(2);
    qDebug()<<str7;

}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    if(ui->textEdit->toPlainText().isEmpty())
    {
        QMessageBox::information(this,"提示","文本为空");
    }
    else
    {
        QString text=ui->textEdit->toPlainText();
        QStringList list=text.split("\n");
        QString ret;
        for(int i=0;i<list.size();i++)
        {
            ret+=list[i][0];
        }
        ui->lineEdit->setText(ret);
    }
}
